<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }.el-table .cell{
      white-space:pre-line;
      text-align: center;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">价格分析</div>
      </div>
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="x-ut-top">
        <div class="x-inc-num">系统参与门店：<span class="x-inc-g">{{personnum}}个</span></div>
        <div class="x-inc-num">本组参与店面：<span class="x-inc-g">{{personnum2}}个</span></div>
      </div>
      <!--  -->
      <div class="x-margin-b">

        <div class="x-train-tabs swiper-container" style="border-top-left-radius:.6rem;border-top-right-radius:.4rem;">
        <div class="swiper-wrapper">
          <div class="swiper-slide x-train-items" v-for="(item,index) in tabsdata" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
        </div>
      </div>

        <template>
          <el-table :data="tabledata" @cell-click="">
            <el-table-column label="品名" width="90" fixed>
              <template slot-scope="scope">
                {{scope.row.title}}
              </template>
            </el-table-column>
            <el-table-column label="存规格" width="">
              <template slot-scope="scope">
                {{scope.row.save_unit}}
              </template>
            </el-table-column>
            <el-table-column :label="'本店数据 \n 日单价/月均价'" width="120">
              <template slot-scope="scope">
                {{scope.row.shop_day}}/{{scope.row.shop_month}}
              </template>
            </el-table-column>
            <el-table-column :label="'本组分析 \n 日最低/日最高/月均值'" width="170">
              <template slot-scope="scope">
                {{scope.row.sys_day_low}}/{{scope.row.sys_day_hight}}/{{scope.row.sys_month}}
              </template>
            </el-table-column>
            <el-table-column :label="'系统分析 \n 日最低/日最高/月均值'" width="170">
              <template slot-scope="scope">
                {{scope.row.group_day_low}}/{{scope.row.group_day_hight}}/{{scope.row.group_month}}
              </template>
            </el-table-column>
          </el-table>
        </template>


      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsid:0,
          thmonth:'',
          tabsdata:'',
          curId:0,
          tabledata:[],
          personnum:0,
          personnum2:0,

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            that.thmonth = value;
            that.getdata()
          }
        });
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year +  month +  day;
        that.thmonth = toMonth;
        that.personnum = $api.getStorage('syscount');
        that.personnum2 = $api.getStorage('groupcount');
        that.getdataban()
      },
      methods: {
        getdataban:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/material/cateList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tabsdata = ret.data.list;
                that.tabsid = ret.data.list[0].id;
                that.getdata()
                that.$nextTick(function(){
                  var mySwiper = new Swiper('.swiper-container',{
                    freeMode: true,
                    loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                    slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                    slidesPerView: 3,
                    centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                    spaceBetween: 10,//slide之间设置距离
                    slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                    slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                  });

                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        getdata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/material/AnalysePriceList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:that.tabsid,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tabledata = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        changetab:function(index,id){
          var that = this;
          that.tabsid = id;
          that.curId = index;
          that.getdata()
        },
      }
    })
	}


	</script>
</body>
</html>
